package com.study.spmongodb.wwj.juc.atomic;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author study
 * @version 1.0
 * @date 2020/12/11 14:40
 */
public class AtomicBooleanFlag {
    private final static AtomicBoolean flag = new AtomicBoolean(true);

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            while (flag.get()) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("i am working……");
            }
        }).start();

        Thread.sleep(10_000);
        flag.set(false);
    }


}
